
package core;

import java.util.ArrayList;
import java.util.HashMap;


/**
 *
 * @author Raed Shomali
 */
public class COINCOMOComponent extends COINCOMOUnit
{
    int multiBuildShift = 0 ;
    
    int scedBase = 0 ;
    int scedIncr = 0 ;
    
    int scaleFactorsBase[] = new int[ 5 ] ;
    int scaleFactorsIncr[] = new int[ 5 ] ;
    
    float totalProd = 0 ;
    float totalCost = 0 ;
    float totalInstCost = 0 ;
    float totalStaff = 0 ;
    float totalEffort = 0 ;
    float totalSchedule = 0 ;
    
    double inceptionEffortPercentage = 6.0 ;
    double elaborationEffortPercentage = 24.0 ;
    double constructionEffortPercentage = 76.0 ;
    double transitionEffortPercentage = 12.0 ;
    
    double inceptionSchedulePercentage = 12.5 ;
    double elaborationSchedulePercentage = 37.5 ;
    double constructionSchedulePercentage = 62.5 ;
    double transitionSchedulePercentage = 12.5 ;

    double inceptionPM = 0.0 ;
    double elaborationPM = 0.0 ;
    double constructionPM = 0.0 ;
    double transitionPM = 0.0 ;
    
    double inceptionM = 0.0 ;
    double elaborationM = 0.0 ;
    double constructionM = 0.0 ;
    double transitionM = 0.0 ;
    
    float scaleFactor = 0.0f ;
    
    //Code by Vishesh, Sheryl, Deepak, Ankoor
   
    String projectName = "";
    
    String projectOrignator = "";
    
    int projectID = 0;
    
    int revNo = 0;
    
    String month = "";
    String day = "";
    String year = "";
    
    String date = "";
    
    double KSLOC = 0;
    double CREVOL = 0;
    
    ArrayList<String> cotsClasses = new ArrayList();
    ArrayList<Integer> cotsClassesId = new ArrayList();
    ArrayList<String> cotsXMLClassess = new ArrayList();
    
    Integer cocot_id;
    int ratings[] = new int[ 18 ] ;
    HashMap<Integer, int[]> cocots_ratings = new HashMap();
    
    //int cocots_rating[] = new int[20];
    
    double projectResult = 0;
    
    //Loaded Cots
    
    HashMap<Integer, int[]> loaded_cocots_ratings = new HashMap();
    
    boolean aggregateLoaded = false;
    
    int numOfTailCots = 0;
    double tailMedianDefault = 0.0;
    
    int numOfInitialAssessCots = 0;
    int numOfFinalAssessCots = 0;
    
    HashMap<Integer, int[]> cocots_assess_ratings = new HashMap();
    HashMap<Integer, int[]> loaded_assess_cocots_ratings = new HashMap();
    
    HashMap<Integer, double[]> cocots_tail_ratings = new HashMap();
    HashMap<Integer, double[]> loaded_tail_cocots_ratings = new HashMap();

    public void setMultiBuildShift( int multiBuildShift )
    {
        this.multiBuildShift = multiBuildShift;
    }

    public float getScaleFactor()
    {
        return scaleFactor;
    }

    public void setScaleFactor( float scaleFactor )
    {
        this.scaleFactor = scaleFactor;
    }
    
    public int getMultiBuildShift()
    {
        return multiBuildShift;
    }

    public int[] getScaleFactorsBase()
    {
        return scaleFactorsBase;
    }

    public void setScaleFactorsBase( int[] scaleFactorsBase )
    {
        this.scaleFactorsBase = scaleFactorsBase;
    }

    public int[] getScaleFactorsIncr()
    {
        return scaleFactorsIncr;
    }

    public void setScaleFactorsIncr( int[] scaleFactorsIncr )
    {
        this.scaleFactorsIncr = scaleFactorsIncr;
    }

    public int getScedBase()
    {
        return scedBase;
    }

    public void setScedBase( int scedBase )
    {
        this.scedBase = scedBase;
    }

    public int getScedIncr()
    {
        return scedIncr;
    }

    public void setScedIncr( int scedIncr )
    {
        this.scedIncr = scedIncr;
    }

    public float getTotalCost()
    {
        return totalCost;
    }

    public void setTotalCost( float totalCost )
    {
        this.totalCost = totalCost;
    }

    @Override
    public float getTotalEffort()
    {
        return totalEffort;
    }

    public void setTotalEffort( float totalEffort )
    {
        this.totalEffort = totalEffort;
    }

    public float getTotalInstCost()
    {
        return totalInstCost;
    }

    public void setTotalInstCost( float totalInstCost )
    {
        this.totalInstCost = totalInstCost;
    }

    public float getTotalProd()
    {
        return totalProd;
    }

    public void setTotalProd( float totalProd )
    {
        this.totalProd = totalProd;
    }

    @Override
    public float getTotalSchedule()
    {
        return totalSchedule;
    }

    public void setTotalSchedule( float totalSchedule )
    {
        this.totalSchedule = totalSchedule;
    }

    public float getTotalStaff()
    {
        return totalStaff;
    }

    public void setTotalStaff( float totalStaff )
    {
        this.totalStaff = totalStaff;
    }

    public void addMultiBuildShift( int multiBuildShift )
    {
        this.multiBuildShift += multiBuildShift;
        
        if( this.multiBuildShift < 0 )
        {
            this.multiBuildShift = 0 ;
        }
    }

    public double getConstructionEffortPercentage()
    {
        return constructionEffortPercentage;
    }

    public void setConstructionEffortPercentage( double constructionEffortPercentage )
    {
        this.constructionEffortPercentage = constructionEffortPercentage;
    }

    public double getConstructionSchedulePercentage()
    {
        return constructionSchedulePercentage;
    }

    public void setConstructionSchedulePercentage( double constructionSchedulePercentage )
    {
        this.constructionSchedulePercentage = constructionSchedulePercentage;
    }

    public double getElaborationEffortPercentage()
    {
        return elaborationEffortPercentage;
    }

    public void setElaborationEffortPercentage( double elaborationEffortPercentage )
    {
        this.elaborationEffortPercentage = elaborationEffortPercentage;
    }

    public double getElaborationSchedulePercentage()
    {
        return elaborationSchedulePercentage;
    }

    public void setElaborationSchedulePercentage( double elaborationSchedulePercentage )
    {
        this.elaborationSchedulePercentage = elaborationSchedulePercentage;
    }

    public double getInceptionEffortPercentage()
    {
        return inceptionEffortPercentage;
    }

    public void setInceptionEffortPercentage( double inceptionEffortPercentage )
    {
        this.inceptionEffortPercentage = inceptionEffortPercentage;
    }

    public double getInceptionSchedulePercentage()
    {
        return inceptionSchedulePercentage;
    }

    public void setInceptionSchedulePercentage( double inceptionSchedulePercentage )
    {
        this.inceptionSchedulePercentage = inceptionSchedulePercentage;
    }

    public double getTransitionEffortPercentage()
    {
        return transitionEffortPercentage;
    }

    public void setTransitionEffortPercentage( double transitionEffortPercentage )
    {
        this.transitionEffortPercentage = transitionEffortPercentage;
    }

    public double getTransitionSchedulePercentage()
    {
        return transitionSchedulePercentage;
    }

    public void setTransitionSchedulePercentage( double transitionSchedulePercentage )
    {
        this.transitionSchedulePercentage = transitionSchedulePercentage;
    }

    public double getMTotal()
    {
        return inceptionM + elaborationM + constructionM + transitionM ;
    }

    public double getMTotalEC()
    {
        return elaborationM + constructionM ;
    }

    public double getPMTotal()
    {
        return inceptionPM + elaborationPM + constructionPM + transitionPM ;
    }

    public double getPMTotalEC()
    {
        return elaborationPM + constructionPM ;
    }

    public double getPTotal()
    {
        return getInceptionP() + getElaborationP() + getConstructionP() + getTransitionP()  ;
    }

    public double getPTotalEC()
    {
        return getElaborationP() + getConstructionP() ;
    }

    public double getConstructionM()
    {
        return constructionM;
    }

    public void setConstructionM( double constructionM )
    {
        this.constructionM = constructionM;
    }

    public double getConstructionP()
    {
        if( constructionM == 0 )
        {
            return 0 ;
        }
        
        return constructionPM / constructionM ;
    }

    public double getConstructionPM()
    {
        return constructionPM;
    }

    public void setConstructionPM( double constructionPM )
    {
        this.constructionPM = constructionPM;
    }

    public double getElaborationM()
    {
        return elaborationM;
    }

    public void setElaborationM( double elaborationM )
    {
        this.elaborationM = elaborationM;
    }

    public double getElaborationP()
    {
        if( elaborationM == 0 )
        {
            return 0 ;
        }
        
        return elaborationPM / elaborationM ;
    }

    public double getElaborationPM()
    {
        return elaborationPM;
    }

    public void setElaborationPM( double elaborationPM )
    {
        this.elaborationPM = elaborationPM;
    }

    public double getInceptionM()
    {
        return inceptionM;
    }

    public void setInceptionM( double inceptionM )
    {
        this.inceptionM = inceptionM;
    }

    public double getInceptionP()
    {
        if( inceptionM == 0 )
        {
            return 0 ;
        }
        
        return inceptionPM / inceptionM ;
    }

    public double getInceptionPM()
    {
        return inceptionPM;
    }

    public void setInceptionPM( double inceptionPM )
    {
        this.inceptionPM = inceptionPM;
    }

    public double getTransitionM()
    {
        return transitionM;
    }

    public void setTransitionM( double transitionM )
    {
        this.transitionM = transitionM;
    }

    public double getTransitionP()
    {
        if( transitionM == 0 )
        {
            return 0 ;
        }
        
        return transitionPM / transitionM;
    }

    public double getTransitionPM()
    {
        return transitionPM;
    }

    public void setTransitionPM( double transitionPM )
    {
        this.transitionPM = transitionPM;
    }
    
    
  //Vishesh, Sheryl, Deepak, Ankoor...........
    /*public void setCocotsRatings( int ratings[] )
    {
    	this.cocots_rating = ratings;
    }*/
    public int[] getRatings()
    {
        return ratings;
    }
    public void setProjectName( String projectName )
    {
    	this.projectName = projectName;
    }
    public String getProjectName()
    {
    	return projectName;
    }
    public void setProjectOriginator( String projectOriginator ) 
    {
    	this.projectOrignator = projectOriginator;
    }
    
    public String getProjectOriginator()
    {
    	return projectOrignator;
    }
    
    public void setProjectID( int projectID )
    {
    	this.projectID = projectID;
    }
    public int getProjectID()
    {
    	return projectID;
    }
    
    
    public void setProjectRevNo( int revNo ) 
    {
    	this.revNo = revNo;
    }
    
    public int getProjectRevNo()
    {
    	return revNo;
    }
    
    public void setKSLOC ( double KSLOC )
    {
    	this.KSLOC = KSLOC;
    }
    public double getKSLOC ()
    {
    	return KSLOC;
    }
    public void setCREVOL ( double CREVOL )
    {
    	this.CREVOL = CREVOL;
    }
    public double getCREVOL ()
    {
    	return CREVOL;
    }
    public void setDateString(String date)
    {
    	this.date = date;
    }
    public void setDate( String year, String month, String day )
    {
    	this.month = month;
    	this.day = day;
    	this.year = year;
    }
    public String getDateString()
    {
    	return date;
    }
    public String getDate()
    {
    	return year + "-" + month + "-" + day;
    }
    public void clearCotClass()
    {
    	cotsXMLClassess = (ArrayList<String>) cotsClasses.clone();
    	cotsClasses.clear();
    	cocots_ratings.clear();
    	cotsClassesId.clear();
    }
    
    public void setAdditionalCotClassID( Integer cotClass )
    {
    	this.cotsClassesId.add(cotClass);
    }
    public void setAdditionalCotClass( String cotClass)
    {
    	this.cotsClasses.add(cotClass);
    }
    
    public void removeAdditionalCotClassID( Integer cotClass )
    {
    	this.cotsClassesId.remove(cotClass);
    }
    public void removeAdditionalCotClass( String cotClass)
    {
    	this.cotsClasses.remove(cotClass);
    }
    
    public ArrayList<String> getCotClass()
    {
    	return cotsClasses;
    }
    
    public ArrayList<String> getXMLCotClass()
    {
    	return cotsXMLClassess;
    }
    
    public ArrayList<Integer> getCotClassID()
    {
    	return cotsClassesId;
    }
    
    public void setCocotID( Integer id )
    {
    	this.cocot_id = id;
    }
    public Integer getCoCotID ()
    {
    	return cocot_id;
    }
    //Glue Code Ratings
    
    
    public HashMap< Integer, int [] > getCocotsRatings()
    {
    	return cocots_ratings;
    }
    public void setCocotsRatings( Integer cocot_id , int[] rating)
    {
    	this.cocots_ratings.put(cocot_id, rating);
    }
    //Tail Code Ratings
    
    public void setNumOfTailCots ( int numOfTailCots )
    {
    	this.numOfTailCots = numOfTailCots;
    }
    
    public int getNumOfTailCots ()
    {
    	return numOfTailCots;
    }
    
    public void setTailMedianDefault(double tailMedianDefault) 
	{
		this.tailMedianDefault = tailMedianDefault;
	}
    
	public double getTailMedianDefault()
	{
		return tailMedianDefault;
	}
    
    
    public HashMap< Integer, double[] > getTailCocotsRatings()
    {
    	return cocots_tail_ratings;
    }
    public void setTailCocotsRatings( Integer cocot_id , double[] ratings)
    {
    	this.cocots_tail_ratings.put(cocot_id, ratings);
    }
    
    
   //Asses Code Ratings
    
    public void setNumOfIntialAssessCots ( int numOfIntialAssessCots )
    {
    	this.numOfInitialAssessCots = numOfIntialAssessCots;
    }
    
    public int getNumOfIntialAssessCots ()
    {
    	return numOfInitialAssessCots;
    }
    
    public void setNumOfFinalAssessCots ( int numOfFinalAssessCots )
    {
    	this.numOfFinalAssessCots = numOfFinalAssessCots;
    }
    
    public int getNumOfFinalAssessCots ()
    {
    	return numOfFinalAssessCots;
    }
    
    
    public HashMap< Integer, int [] > getAssessCocotsRatings()
    {
    	return cocots_assess_ratings;
    }
    public void setAssessCocotsRatings( Integer cocot_id , int[] rating)
    {
    	this.cocots_assess_ratings.put(cocot_id, rating);
    }
    
    
    
    
    public void setProjectResult ( double projectResult )
    {
    	this.projectResult = projectResult;
    }
    
    public double getProjectResult ()
    {
    	return projectResult;
    }
    
    //Loaded Cots
    
    
    //Glue Code
    public void setLoadedCocotRatings( Integer cocot_id , int[] rating )
    {
    	this.loaded_cocots_ratings.put(cocot_id, rating);
    }
    
    public HashMap< Integer, int [] > getLoadedCocotsRatings()
    {
    	return loaded_cocots_ratings;
    }
    
    public void deleteLoadedCocotsRatings ( Integer cocot_id )
    {
    	loaded_cocots_ratings.remove( cocot_id );
    }
    
    public void clearLoadedCocotsRatings ()
    {
    	loaded_cocots_ratings.clear();
    }
    
    //Tail Code
    public void setLoadedTailCocotRatings( Integer cocot_id , double[] rating )
    {
    	this.loaded_tail_cocots_ratings.put(cocot_id, rating);
    }
    
    public HashMap< Integer, double[] > getLoadedTailCocotsRatings()
    {
    	return loaded_tail_cocots_ratings;
    }
    
    public void deleteLoadedTailCocotsRatings ( Integer cocot_id )
    {
    	loaded_tail_cocots_ratings.remove( cocot_id );
    }
    
    public void clearLoadedTailCocotsRatings ()
    {
    	loaded_tail_cocots_ratings.clear();
    }
    
    //Assess Code
    public void setLoadedAssessCocotRatings( Integer cocot_id , int[] rating )
    {
    	this.loaded_assess_cocots_ratings.put(cocot_id, rating);
    }
    
    public HashMap< Integer, int [] > getLoadedAssessCocotsRatings()
    {
    	return loaded_assess_cocots_ratings;
    }
    
    public void deleteLoadedAssessCocotsRatings ( Integer cocot_id )
    {
    	loaded_assess_cocots_ratings.remove( cocot_id );
    }
    
    public void clearLoadedAssessCocotsRatings ()
    {
    	loaded_assess_cocots_ratings.clear();
    }
    
    
    public void setAggregateLoaded()
    {
    	aggregateLoaded = true;
    }
    
    public boolean getAggregateLoaded()
    {
    	return aggregateLoaded;
    }
}
